﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<link href="js-console.css" rel="stylesheet" />
	<script src="string-extensions.js"></script>
	<!-- 6. Write a function that extracts the content of a html 
			page given as text. The function should return 
			anything that is in a tag, without the tags:
		<html><head><title>Sample 
		site</title></head><body><div>text<div>more 
		text</div>and more...</div>in body</body></html>
		result: Sample sitetextmore textand more...in body  -->
	<style>
		textarea, button {
			display: block;
			width: 800px;
		}
	</style>
</head>
<body>
	<textarea id="input" placeholder="Enter HTML for extracting text"></textarea>
	<button onclick="doChange()">Change Text</button>
	<div id="js-console"></div>
	<script src="js-console.js"></script>
	<script>
		function removeTags(input) {
			return input.replace(/(<([^>]+)>)/ig, '');
		}

		// Button OnClick
		function doChange() {
			// Read User input
			var input = jsConsole.read("#input");

			// Output
			jsConsole.writeLine("You have entered (escaped):");
			jsConsole.writeLine("<blockquote>" + input.htmlEscape() + "</blockquote>");

			// Remove all tags
			var result = removeTags(input);
			jsConsole.writeLine("Result:");
			jsConsole.writeLine("<blockquote>" + result + "</blockquote>");
		}
	</script>
</body>
</html>
